# 冰山
from collections import defaultdict

MOD = 998244353


def sum_ice_vol_simulation(k, vols, deltas):
    """最简单的模拟, 存储冰山体积的数组vols超过了内存限制"""
    for x, y in deltas:
        vanish = []
        for i in range(len(vols)):
            vol = vols[i] + x
            if vol > k:  # 分裂为多个冰山
                vols[i] = k
                for j in range(vol - k):
                    vols.append(1)
            elif vol <= 0:  # 记录体积消失的冰山
                vanish.append(i)
            else:
                vols[i] = vol
        for reduce, idx in enumerate(vanish):  # 删除消失的冰山
            vols.pop(idx - reduce)
        vols.append(y)  # 添加飘来的冰山
        print(sum(vols) % 998244353)


def sum_ice_vol_map(k, vols, deltas):
    """摘抄的答案, 有些代码的写法很值得参考, 另外这种取余数的题目需要在每个对结果有直接影响的加法的地方取余"""
    mapping = defaultdict(int)  # 记录火山体积的字典 1:2 表示有两个体积为1的冰山
    for v in vols:
        mapping[v] += 1

    for x, y in deltas:
        mapping = {key + x: val % MOD for key, val in mapping.items() if key + x > 0}  # 消失的冰山不再记录
        for key, val in mapping.copy().items():
            if key > k:
                del mapping[key]
                mapping[1] = (mapping.get(1, 0) + (key - k) * val) % MOD
                mapping[k] = (mapping.get(k, 0) + val) % MOD
        if y != 0:
            mapping[y] = (mapping.get(y, 0) + 1) % MOD  # 添加飘来的火山

        res = (sum((key * val) % MOD for key, val in mapping.items())) % MOD
        print(res)


if __name__ == '__main__':
    n, m, k = map(int, input().split())
    v = list(map(int, input().split()))
    deltas = []
    for _ in range(m):
        deltas.append(tuple(map(int, input().split())))

    sum_ice_vol_map(k, v, deltas)

"""
312264
200240
361106
46451661
131053944
53041744
309323375
78653

270305
200240
208562
399417
670616
1004198
1131640
1387017
76235
"""
